﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using University.Workshop.DataAccess;
using University.Workshop.Model;

namespace University.Workshop.Business
{
    public static class WebmasterManager
    {
        public static Webmaster RegisterWebmaster(string userEmail, bool canRespondTickets, bool canSetWebmasters )
        {
            User user = UserDataAccess.GetUserByEmail(userEmail);
            Webmaster webmaster = new Webmaster
                                      {
                                          UserId = user.Id,
                                          CanRespondTickets = canRespondTickets,
                                          CanSetWebmasters = canSetWebmasters
                                      };
            return WebmasterDataAccess.InsertWebmaster(webmaster);
        }

        public static bool IsWebmaster(string userEmail)
        {
            User user = UserDataAccess.GetUserByEmail(userEmail);
            if (user != null)
            {
                Webmaster webmaster = WebmasterDataAccess.GetWebmasterByUserId(user.Id);
                return webmaster != null;
            }
            else
            {
                return false;
            }
        }
    }
}
